<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>class</title>
</head>

<body>
    <div id="app"></div>

    <script src="./1.js"></script>
    <script src="./2.js"></script>
    <script src="./3.js"></script>

    <script type="text/babel">
        function List() {
            let arr = []
            setTimeout(function () {
                arr = ['111', '222', '333', '444']
            }, 2000)

            return (
                <ul>
                    {
                        arr.map((v, i) => <li key={i}>{v}</li>)
                    }
                </ul>
            )
        }

        class List2 extends React.Component {
            constructor() {
                super()
                this.state = {
                    arr: [],
                    time: ""
                }
            }
            componentDidMount() {
                setTimeout(() => {
                    this.setState({
                        arr: ['111', '222', '333', '444']
                    })
                }, 2000)

                setInterval(() => {
                    this.setState({
                        time: new Date().toLocaleString()
                    })
                }, 1000)


            }

            render() {
                return (
                    <ul>
                        {
                            this.state.arr.map((v, i) => <li key={i}>{v}</li>)
                        }
                        <p>{this.state.time}</p>
                    </ul>
                )
            }

        }


        ReactDOM.render(
            <div>
                <List></List>
                <List2></List2>
            </div>,
            document.getElementById('app')
        )
    </script>


</body>

</html>